import { useStore } from '@/store';
import { defineStore } from 'pinia'
import { getTalkMessage } from "@/api/im";

export const useIMChatStore = defineStore("IMChat", () => {
    const chatList = ref<any>([]);

    const store = useStore();

    //actions
    const addItems = (item: any) => {
        //Find the object whose id is similar to the item
        const checkItems = chatList.value.find((x: any) => x.id === item.id);
        if (!checkItems) {
            chatList.value.push(item);
        }
    };
    const removeItems = (id: string) => {
        chatList.value = chatList.value.filter((x: any) => x.id !== id);
    };
    return { chatList, addItems, removeItems };
});

